{extend name="main" /}

{block name="body"}
{include file="breadcrumb" /}
<div class="layui-fluid">
    <div class="layui-card">
        <div class=" layui-card-header layuiadmin-card-header-auto">
            {include file="member_logs/index_form"}
        </div>
        <div class="layui-card-body">
            <table class="layui-hide layui-table" id="test"  lay-filter="test"></table>
        </div>
    </div>



<!--html模版列表-->
{include file="member_logs/index_tpl"}

</div>
{/block}
{block name="js"}
<script src="/static/admin/js/layuiTableApi.js"></script>
<script>
        var table = layui.table,form = layui.form,laytpl  = layui.laytpl ;
        var cols = [
            {"type":"checkbox"},
            {"field":"id","title":"ID"},
            {"field":"username","title":"用户名"},
            {"field":"headimg","title":"头像","templet":"#imageHeadimgTpl"},
            {"field":"nickname","title":"昵称"},
            {"field":"role_text","title":"级别"},
            {"field":"status","title":"状态","templet":"#switchStatusTpl"},
            {"field":"create_time","title":"创建时间"},
            {"title":"操作","templet":"#apiListBar","width":200}
        ];
        //表格初始化
        table.render(getLayuiInit('#test','index.html',cols));

        //监听单行工具条
        table.on('tool(test)',(obj)=>{
        var data = obj.data;
        if(obj.event === 'del'){
            layuiApiDel(data,()=>{obj.del()})
                } else if(obj.event === 'edit'){
            //渲染并加载模板
            ajax_open('用户管理1编辑','edit.html?id='+data.id,'600px','450px')
            // setTimeout(()=>{form.render();},1000);
            // laytpl(editData.innerHTML).render(data,function(html){
            //     layuiApiEdit(html,'用户管理1编辑','600px','450px');
            //     form.render();
            // })
                }
        });

        //表格顶部工具栏事件
        table.on('toolbar(test)', (obj)=>{
            var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
            switch(obj.event){
                //批量删除
                case 'dels':
                    var data = checkStatus.data;  //获取选中行数据
                    if(data.length==0){
                        layer.msg('请选择要删除的数据！',{icon:5});return ;
                    }
                    layuiApiDel(data,()=>{table.reload('test',{})});break;
                case 'export':
                    apiExport();
                    break;
            };
        });

        //触发排序事件
        table.on('sort(test)', OnLayuiOrder);

        //监听状态操作
        form.on('switch(switchTpl)', OnLayuiSwitch);

        //监听数据提交事件
        form.on('submit(save)', OnLayuiSave);
</script>
{/block}
